{extend name="base"}
{block name="body"}
<ol class="breadcrumb">
  <li><a href="#">首页</a></li>
  <li><a href="{:url('Goods/goods_brand')}">品牌管理</a></li>
  <li class="active">添加品牌</li>
</ol>
<form class="form-horizontal" method="post" enctype="multipart/form-data">
  <div class="form-group">
    <label for="name" class="col-sm-1 control-label">品牌名称</label>
    <div class="col-sm-6">
      <input type="text" class="form-control" id="name" name="name" placeholder="品牌">
    </div>
  </div>
  <div class="form-group">
    <label for="initial" class="col-sm-1 control-label">品牌首字母</label>
    <div class="col-sm-2">
      <input class="form-control" name="initial" placeholder="品牌的首字母,便于检索">
    </div>
  </div>
  <div class="form-group">
    <label for="category" class="col-sm-1 control-label">品牌分类</label>
    <div class="col-xs-2">
        <select class="form-control" id="select_category" name="category_id_1">
          <option>选择分类</option>
          {foreach name="categoryList" id="category_list"}
          <option value="{$category_list.id}">{$category_list.cname}</option>
          {/foreach}
        </select>
    </div>
    <div class="col-xs-2">
        <select class="form-control" name="category_id_2" id="select_category_2">
          <option>选择子类</option>
        </select>
    </div>
    <div class="col-xs-2">
        <select class="form-control" name="category_id_3" id="select_category_3">
          <option>选择子类</option>
        </select>
    </div>
  </div>
  <div class="form-group">
    <label for="logo" class="col-sm-1 control-label">品牌logo</label>
    <div class="col-sm-6">
      <input type="file" class="form-control" name="logo" id="logo">
    </div>
  </div>
  <div class="form-group">
    <label for="brank_desc" class="col-sm-1 control-label">品牌描述</label>
    <div class="col-sm-6">
  		<textarea class="form-control" rows="3" name="desc"></textarea>
  	</div>
  </div>
  <div class="form-group">
    <div class="col-sm-offset-1 col-sm-11">
      <button type="submit" class="btn btn-default">提交</button>
    </div>
  </div>
</form>
<script>
  $("#select_category").change(function(){
    $("#select_category option").each(function(){
      if($(this).prop("selected")){
        var pid=this.value;
        $.get('{:url('getCateTwo')}',{pid:pid},function(r){
          $("#select_category_2").html(r);
        });
      }
    });
  });
  $("#select_category_2").change(function(){
    var pid=this.value;
    $.get('{:url('getCateTwo')}',{pid:pid},function(r){
      $("#select_category_3").html(r);
    });
  });
</script>
{/block}